// with polyfills
import 'core-js/stable'
import 'regenerator-runtime/runtime'
import 'ant-design-vue/dist/antd.css'
import App from './App.vue'
import router from './router'
import store from './store/'
import i18n from './locales'
import VueDND from 'awe-dnd'
import moment from 'moment'
import Fragment from 'vue-fragment'
import { VueAxios } from './utils/request'
// import ProLayout, { PageHeaderWrapper } from '@ant-design-vue/pro-layout'
import ProLayout from '@ant-design-vue/pro-layout'
import PageHeaderWrapper from '@/layouts/HideBreadCrumb'
import PageTabList from '@/layouts/PageTabList'
import diyObser from './store/diyObser'
import { FormModel, Slider } from 'ant-design-vue'
import themePluginConfig from '../config/themePluginConfig'
import VueClipboard from 'vue-clipboard2'
// 引入swiper
import Swiper from 'swiper'
import 'swiper/dist/css/swiper.css'
import { Carousel, CarouselItem, Tooltip, Input, Image, TimePicker } from 'element-ui'
import Print from 'vue-print-nb'

// mock
// WARNING: `mockjs` NOT SUPPORT `IE` PLEASE DO NOT USE IN `production` ENV.
// import './mock'
import '@/assets/iconfont/icon.css'
import bootstrap from './core/bootstrap'
import './core/lazy_use' // use lazy load components
import './permission' // permission control
import './utils/filter' // global filter
import './global.less' // global style
import { getBaseSetting } from '@/api/saas/setting'

Vue.config.productionTip = false
Vue.config.devtools = true
Vue.prototype.$moment = moment
Vue.prototype.$swiper = Swiper
Vue.prototype.$diyObser = diyObser
Vue.use(Carousel)
  .use(CarouselItem)
  .use(Tooltip)
  .use(Input)
  .use(Image)
  .use(VueDND)
  .use(TimePicker)
  .use(Fragment.Plugin)
Vue.use(VueClipboard)
// mount axios to `Vue.$http` and `this.$http`
Vue.use(FormModel).use(Slider)
Vue.use(VueAxios)
// use pro-layout components
Vue.component('pro-layout', ProLayout)
Vue.component('page-container', PageHeaderWrapper)
Vue.component('page-header-wrapper', PageHeaderWrapper)
Vue.component('page-tab-list', PageTabList)
window.umi_plugin_ant_themeVar = themePluginConfig.theme
//  全局组件之间通信
Vue.prototype.$eventHub = Vue.prototype.$eventHub || new Vue()
// 浏览器打印
Vue.use(Print)

getBaseSetting({}).then(res => {
  if (res.code == 0) {
    store.commit('SET_ADMIN_NAME', res.data.admin_name)
    store.commit('SET_ADMIN_LOGO', res.data.admin_logo)
    store.commit('SET_ADMIN_COPYRIGHT', res.data.admin_copyright)
    store.commit('SET_HELP_LOGO', res.data.help_logo)
    store.commit('SET_DESCRIBE', res.data.describe)
    store.commit('SET_PASSPORT_BG', res.data.passport_bg || '')
  }
})

new Vue({
  router,
  store,
  i18n,
  // init localstorage, vuex
  created: bootstrap,
  render: h => h(App),
  data: {
    eventHub: new Vue() // 全局eventBus
  }
}).$mount('#app')
